/* v-copy 复制指令 */
import { Message } from "element-ui";

export default {
	bind(el) {
		// 双击触发复制
		el.style.cursor = "copy";
		el.style["user-select"] = "none";
		el.addEventListener("dblclick", function (e) {
			const textarea = document.createElement("textarea");
			textarea.setAttribute("style", "position:fixed;top:0;left:0;opacity:0;z-index:-1000;");
			textarea.style.background = "transparent";
			textarea.value = el.innerText;
			document.body.appendChild(textarea);
			textarea.select();
			document.execCommand("copy");
			document.body.removeChild(textarea);
			Message.success({
				message: "ok",
			});
		});
	},
};
